package com.itheima.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 退出的servlet
 */
@WebServlet("/OutServlet")
public class OutServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //清空会话区  消除会话区中的用户对象  会话立即失效
        request.getSession().invalidate();
        //跳转到登录页面
        response.sendRedirect("user-login.html");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws  IOException {
        this.doPost(request, response);
    }
}
